package com.gozap.socket.think;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.Socket;

public class JabberClient {
	public static void main(String[] args) throws IOException {
		Socket socket = new Socket();
		try {
			String host = "";
			host = "redis.service.labi.com";
			host = "192.168.9.1";
			socket.connect(new InetSocketAddress(host, 46378), 2000);
			BufferedReader in = new BufferedReader(new InputStreamReader(
					socket.getInputStream()));
			PrintWriter out = new PrintWriter(new BufferedWriter(
					new OutputStreamWriter(socket.getOutputStream())), true);

			out.println("the hello world is ok");
			String str = in.readLine();
			System.out.println(str);
			// for (int i = 5; i < 10; i++) {
			// out.println("howdy " + i);
			// String str = in.readLine();
			// System.out.println(str);
			// }
			// out.println("END");
		} finally {
			System.out.println("closing...");
			socket.close();
		}
	}
}
